//
//  TCAudienceBarrgeCell.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/7/16.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class TCAudienceBarrgeCell: TableRowView {

    var isCurrent:Bool = false {
        didSet {
            self.nameLab.backgroundColor = isCurrent ?color_green190:color_gray(200)
        }
    }
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        self.setupUI()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


    func setupUI() {
        
        self.backgroundColor = NSColor.clear
        
        self.addSubview(nameBg)
        nameBg.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalTo(10)
            make.height.equalToSuperview()
            make.width.equalTo(BarrgeContainerNameWidth)
        }
        
        nameBg.addSubview(nameLab)
        nameLab.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(8)
            make.right.equalTo(-5)
            make.height.equalTo(20)
            make.width.lessThanOrEqualToSuperview()
        }
        
        self.addSubview(textLab)
        textLab.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10)
            make.left.equalTo(nameBg.snp.right)
            make.right.equalTo(-30)
        }
    }
    
    lazy var nameLab: NSLabel = {
        let lab = NSLabel.label(title: "...", textColor: color_gray(255), font: NSFont.systemFont(ofSize: 12))
        lab.backgroundColor = color_gray(200)
        lab.wantsLayer = true
        lab.alignment = .center
        lab.sizeToFit()
        return lab
    }()
    
    lazy var nameBg: NSView = {
        let view = NSView.init()
        return view
    }()
    
    lazy var textLab: NSLabel = {
        let lab  = NSLabel.label(title: "__", textColor: color_dark160, font: NSFont.systemFont(ofSize: 12))
        lab.preferredMaxLayoutWidth = 30
        lab.maximumNumberOfLines = 0
        lab.cell?.usesSingleLineMode = false
        lab.cell?.wraps = true
        lab.cell?.lineBreakMode = .byCharWrapping
        lab.sizeToFit()
        return lab
    }()
}
